﻿using SuperX.Common.Object;
using System;
using System.Collections.Generic;
using System.Text;

namespace SuperX.DataService
{
    public class ArgumentModel
    {
        /// <summary>
        /// 值
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// 输入类型
        /// </summary>
        public InputType Type { get; set; }

        /// <summary>
        /// 下拉选项
        /// </summary>
        public List<DropItem> DropList { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 是否必填
        /// </summary>
        public bool Required { get; set; }

        /// <summary>
        /// 值否同步
        /// </summary>
        public bool ValueSync { get; set; }

        /// <summary>
        /// 文件夹配置
        /// </summary>
        public List<FileAnalysisConfig> FileAnalysis { get; set; }

        /// <summary>
        /// 校验类型
        /// </summary>
        public CheckType CheckType { get; set; }

        public static ArgumentModel CreateArgument(string value, string description, InputType inputType = InputType.TextBox)
        {
            return new ArgumentModel
            {
                Value = value,
                Description = description,
                Type = inputType,
            };
        }

        public static ArgumentModel CreateArgument(string value, string description, List<DropItem> items, InputType inputType = InputType.TextBox)
        {
            return new ArgumentModel
            {
                Value = value,
                Description = description,
                Type = inputType,
                DropList = items
            };
        }

        public static ArgumentModel CreateArgument(List<FileAnalysisConfig> value, string description, InputType inputType = InputType.TextBox)
        {
            return new ArgumentModel
            {
                FileAnalysis = value,
                Description = description,
                Type = inputType,
            };
        }
    }

    public enum InputType
    {
        None = 0,

        /// <summary>
        /// 只读
        /// </summary>
        ReadOnly = 1,

        /// <summary>
        /// 文本输入框
        /// </summary>
        TextBox = 2,

        /// <summary>
        /// 下拉
        /// </summary>
        DropDown = 3,

        /// <summary>
        /// 文件选择器
        /// </summary>
        FilePath = 4,

        /// <summary>
        /// 单选框
        /// </summary>
        Radio = 5,

        /// <summary>
        /// 文件浏览
        /// </summary>
        FileBrowse = 6,
    }

    public enum CheckType
    {
        None = 0,

        /// <summary>
        /// IP校验
        /// </summary>
        IPAddr = 1,
    }

    public class DropItem
    {
        public string Name { get; set; }

        public string Value { get; set; }
    }
}